#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

void test(int arr1[], int i, int* px)
{
    arr1[*px] = i % 10;
    (*px)++;
    if (i / 10 != 0)
    {
        test(arr1, i / 10, px);
    }
}

int main()
{
    int n = 0;
    scanf("%d", &n);
    int arr1[6] = { 0 };
    int arr2[6] = { 0 };
    if (n >= 1 && n <= 100000)
    {
        int i = 0;
        for (i = 1; i < 10; i++)
        {
            if (i / 10 == 0 && i % 10 != 0)
            {
                printf("%d ", i);
            }
        }
        for (i = 10; i < n; i++)
        {
            int j = 0;
            int count = 0;
            test(arr1, i, &count);
            int k = 5;
            while (k)
            {
                if (i / ((int)pow(10, k)) != 0)
                {
                    arr2[0] = i / ((int)pow(10, k));
                    for (j = 1; j <= count - 2; j++)
                    {
                        if (k > 1)
                        {
                            arr2[j] = (i % ((int)pow(10, k))) / ((int)pow(10, k - 1));
                            k--;
                        }
                    }
                    arr2[count - 1] = i % 10;
                    break;
                }
                k--;
            }
            int count1 = 0;
            for (j = 0; j < count; j++)
            {
                if (arr1[j] == arr2[j])
                {
                    count1++;
                }
            }
            if (count1 == count)
            {
                printf("%d ", i);
            }
        }
    }
    return 0;
}